<?php
/**
 * Created by PhpStorm.
 * User: tengwei
 * Date: 2018/11/16
 * Time: 3:29 PM
 */
namespace common\sources\write\message;
use common\models\craftsman\SmsCode;
use Yii;
class MesgAccess implements IMesgAccess
{

    public function saveCode($data)
    {
        return Yii::$app->db->createCommand()->insert('sms_code', [
            'phone' => $data['phone'],
            'type' => $data['smstype'],
            'verifycode' => $data['verifycode'],
            'sendtime' => $data['sendtime'],
        ])->execute();
    }

    public function modifyCodeStatus($code_id){
        return SmsCode::find()->where(['id' => $code_id])->one()->delete();
//        $sql = 'UPDATE ' . SmsCode::tableName() . ' SET status = :status,update_time=:update_time WHERE id = :id ';
//        return Yii::$app->db->createCommand($sql)
//            ->bindValues([
//                ':status' => 0,
//                ':update_time' => time(),
//                ':id' => $code_id
//            ])->execute();
    }
}